package team.kirohuji.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import team.kirohuji.dao.SystemRoleDao;
import team.kirohuji.domain.SystemRole;
import team.kirohuji.service.SystemRoleService;

@Service("systemRoleService")
public class SystemRoleServiceImpl implements SystemRoleService {
	/**
	 * @see SystemRoleDao systemRoleDao
	 */
	@Resource
	private SystemRoleDao systemRoleDao;

	/*
	 * 查询一条记录 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#queryObject(java.lang.Integer)
	 * 
	 * @param roleId 角色Id
	 * 
	 * @return SystemRole
	 */
	@Override
	public SystemRole queryObject(Integer roleId) {
		return null;
	}

	/*
	 * 查询一组记录 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#queryList(java.util.Map)
	 * 
	 * @param map map对象
	 * 
	 * @return SystemRole列表
	 */
	@Override
	public List<SystemRole> queryList(Map<String, Object> map) {
		return null;
	}

	/*
	 * 查询总记录条数 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#queryTotal(java.util.Map)
	 * 
	 * @param map map对象
	 * 
	 * @return int
	 */
	@Override
	public int queryTotal(Map<String, Object> map) {
		return 0;
	}

	/*
	 * 存入 (non-Javadoc)
	 * 
	 * @see
	 * team.kirohuji.service.SystemRoleService#save(team.kirohuji.domain.SystemRole)
	 * 
	 * @param role 角色
	 */
	@Override
	public void save(SystemRole role) {

	}

	/*
	 * 更新 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#update(team.kirohuji.domain.
	 * SystemRole)
	 * 
	 * @param role 角色
	 */
	@Override
	public void update(SystemRole role) {

	}

	/*
	 * 批量删除 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#deleteBatch(java.lang.Integer[])
	 * 
	 * @param roleIds 角色主键数组
	 */
	@Override
	public void deleteBatch(Integer[] roleIds) {

	}

	/*
	 * 查询角色列表 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#queryRoles()
	 * 
	 * @return SystemRole列表
	 */
	@Override
	public List<SystemRole> queryRoles() {
		return systemRoleDao.queryRoles();
	}

	/*
	 * 插入一条记录 (non-Javadoc)
	 * 
	 * @see team.kirohuji.service.SystemRoleService#insertRole(team.kirohuji.domain.
	 * SystemRole)
	 * 
	 * @param systemRole 系统角色
	 * 
	 * @return boolean
	 */
	@Override
	public boolean insertRole(SystemRole systemRole) {

		List<SystemRole> roles = systemRoleDao.queryRoles();
		for (SystemRole role : roles) {
			if (role.getRoleName().equals(systemRole.getRoleName()))
				return false;
		}
		Date createDate = new Date();
		systemRole.setCreateDate(createDate);
		systemRoleDao.save(systemRole);
		return true;
	}
}